]> git.dpolakovic.space - dpolakovic-space/commitdiff
feat: Added script for parsing blog contents to RSS. master 1.2.0
authorDavid Polakovic
Sun, 8 Mar 2026 13:08:13 +0000 (14:08 +0100)
committerDavid Polakovic
Sun, 8 Mar 2026 13:08:13 +0000 (14:08 +0100)
Scripts/Rsser/rsser.pl [new file with mode: 0644]

diff --git a/Scripts/Rsser/rsser.pl b/Scripts/Rsser/rsser.pl
new file mode 100644 (file)
index 0000000..f6b427c
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+# Check if filename argument is provided
+if (@ARGV != 1) {
+    print "perl script.pl yourfile.txt > output.txt\n";
+    exit 1;
+}
+
+my $filename = $ARGV[0];
+
+# Read the entire file
+open(my $fh, '<', $filename) or die "Cannot open file '$filename': $!\n";
+my $content = do { local $/; <$fh> };
+close($fh);
+
+# Replace <i> with <em>
+$content =~ s/<i>/<em>/g;
+$content =~ s/<\/i>/<\/em>/g;
+
+# Replace <b> with <strong>
+$content =~ s/<b>/<strong>/g;
+$content =~ s/<\/b>/<\/strong>/g;
+
+# Delete <div...> opening tags only (keep content, delete closing tags)
+$content =~ s/<div[^>]*>//g;
+
+# Delete remaining </div> tags (in case there are unmatched ones)
+$content =~ s/<\/div>//g;
+
+# Delete <center> and </center> tags
+$content =~ s/<center>//g;
+$content =~ s/<\/center>//g;
+
+# Replace <a href="#notes">*</a> with just the asterisks
+$content =~ s/<a href="#notes">(\*+)<\/a>/$1/g;
+
+# Replace multiple whitespaces with single space
+$content =~ s/\s+/ /g;
+
+# Put everything on a single line (remove newlines)
+$content =~ s/\n/ /g;
+
+# Trim leading and trailing whitespace
+$content =~ s/^\s+|\s+$//g;
+
+# Print the result
+print $content . "\n";
\ No newline at end of file
Copyright 2022-2026 David Polakovic. Individual project licenses are located in project root in full length.

Site generated using Gitweb. Read the documentation for JavaScript and cookie information. Additional source code available here under GPLv3 license.

Server for this subdomain is RFC 2324 compliant